package com.yonyou.nc.richeditor;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.text.EditorKit;
import javax.swing.text.StyledEditorKit;

public class App {

	public static void main(String[] args) {
		
		JFrame frame = new JFrame();
		frame.setSize(600,400);
		frame.setTitle("StyledEditorKit Demo");
		
		
		BorderLayout layout = new BorderLayout();
		frame.setLayout(layout);
		
		Pane pane = new Pane();
		frame.add(pane,BorderLayout.CENTER);
		pane.setVisible(true);
		
		//pane.getEditorKit();
		
		JPanel panel = new JPanel();
		JToolBar toolBar = new JToolBar("Still draggable");
		panel.add(toolBar);
		JButton btn1 = new JButton("New");
		toolBar.add(btn1);
		JButton btn2 = new JButton("Copy");
		toolBar.add(btn2);
		JButton btn3 = new JButton("Paste");
		toolBar.add(btn3);
		
		JComboBox fonts = new JComboBox(new String[]{"宋体","微软雅黑"});
		toolBar.add(fonts);
		
		
		
		frame.add(panel,BorderLayout.NORTH);
		
		
		JButton btn = new JButton("Demo");
		frame.add(btn,BorderLayout.SOUTH);
		
		/**
		 * StyledEditorKit.BoldAction()  粗体
			StyledEditorKit.UnderlineAction();   下划线
			StyledEditorKit.ItalicAction();    斜体
			StyledEditorKit.FontFamilyAction("宋体", "宋体")  宋体
			tyledEditorKit.FontSizeAction(“12”, 12)  字体大小
			StyledEditorKit.ForegroundAction("Black",Color.black); 字体颜色
		 */
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
		
	}
	
	
	
	
}

final class Pane extends JEditorPane{

	private static final long serialVersionUID = 2204819477479999223L;

	@Override
	protected EditorKit createDefaultEditorKit() {
		return new StyledEditorKit();
	}
	
}
